/*
 * @Date: 2023-02-25 17:23:00
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-03-11 09:38:26
 * @FilePath: \A19\backend\src\api\Get\ApiGetTestInfo.ts
 */
import { ApiCall } from "tsrpc";
import { ReqGetTestInfo, ResGetTestInfo } from "../../shared/protocols/Get/PtlGetTestInfo";
import { Global } from '../../Global/index';

export default async function (call: ApiCall<ReqGetTestInfo, ResGetTestInfo>) {
    // TODO
    const eOrh = call.req.examOrHomework

    const test = await Global.collection(eOrh === 'exam'?'tests':'homework').findOne({
        _id:call.req.testId
    })
    if(test){
    //    if(test.endTime > new Date){
    //     // console.log(test);
        
        
    //    }
    //    else{
    //     call.error('考试已结束')
    //    }
       call.succ({testInfo:test})
        // call.succ({
        //     testInfo:test
        // })
    }
    else{
        call.error('考试不存在')
    }
}